package cate.game.activity.limitshop.paycallback;

import cate.common.table.d.GDFunc;
import cate.common.table.pay.PayItemRow;
import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.activity.base.core.RoleActivitySingle;
import cate.game.activity.limitshop.LimitShopActivity;
import cate.game.pay.PayCallback;
import cate.game.pay.PayHandler;
import cate.game.role.Role;
import cp.solution.business.pay.PayRecordEntity;
import cp.solution.business.pay.dto.PayDeliverResult;
import easy.java.dev.note.NoteClass;

@NoteClass("限购商店 充值回调")
@PayHandler(funcIds = {
        GDFunc.MergeAct.MERGE_ACT_SHOP,
        GDFunc.UP_POOL_FAIRY_GIFT,
        GDFunc.UP_POOL_HERO_GIFT,
        GDFunc.UP_POOL_STRONG_HERO_GIFT,
        GDFunc.GOLD_EGG_GIFT,
        GDFunc.CONVERT_HERO_GIFT,
        GDFunc.LUCKY_BAG_GIFT,
        GDFunc.LIMIT_BACK_GIFT,
        GDFunc.SPE_CALL_SHOP,
        GDFunc.Help.GOLD_COMEON_SHOP,
        GDFunc.Help.HERO_STAR_UP_SHOP,
        GDFunc.Help.DAILY_GIFT_SHOP,
        GDFunc.Help.HERO_CALL_SHOP,
        GDFunc.Help.NATURE_HERO_CALL_SHOP,
        GDFunc.Help.GEMS_ON_SHOP,
        GDFunc.Help.SPICE_CALL_SHOP,
        GDFunc.Help.M1_CONSUME_SHOP,
        GDFunc.Help.GOD_EQUIP_SHOP,
        GDFunc.Help.RUNE_RECAST_SHOP,
        GDFunc.Help.MALL_BUY_SHOP,
        GDFunc.Help.ELITE_CALL_SHOP,
        GDFunc.LOST_DREAMLAND_GIFT,
        GDFunc.LOTTERY_GIFT,
        GDFunc.SKIN_DRAW_GIFT,
        GDFunc.MOONCAKE_SHOP,
        GDFunc.Help.CROSS_SPICE_CALL_SHOP,
        GDFunc.Help.CROSS_WISH_CRYSTALL_SHOP,
        GDFunc.Help.WISH_CRYSTAL_SHOP,
        GDFunc.NEW_HERO_GIFT,
        GDFunc.Help.CROSS_DIAMOND_SHOP,
        GDFunc.Help.CROSS_GOD_EQUIP_SHOP,
        GDFunc.SB_SHOP_1,
        GDFunc.SB_SHOP_2
})
public class PayLimitShopCallback extends PayCallback {
    @Override
    public void onSuccess(GameBody game, Role role, PayRecordEntity record, PayDeliverResult result) {
        PayItemRow pir = game.table.pay.item.get(record.itemTid);
        if (pir == null) {
            return;
        }
        RoleActivitySingle single = role.getActivity().getEnableActivitySingle(pir.funcId);
        if (single != null) {
            single.onPaySuccess(pir);
        }
    }

    @Override
    public void onFail(GameBody game, Role role, PayRecordEntity record, PayDeliverResult result) {

    }

    @Override
    public GameResult<Void> allowPay(Role role, PayItemRow pir) {
        LimitShopActivity act = role.getActivity().getEnableActivitySingle(pir.funcId);
        if (act != null) {
            GameResult<Void> ecResult = act.allowPay(pir);
            if (ecResult != null) return ecResult;
        }
        return new GameResult<Void>().fail();
    }
}
